package tcln.sors.model.order.dom;

import java.util.Date;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.validator.Min;
import org.hibernate.validator.NotNull;

import tcln.sors.model.base.dom.AbstractSorsEntity;

/**
 * @author Truong Chau Lien Ngoc (lienngoc@gmail.com)
 * 
 */
@Entity
@Table(name = "TBL_ORDER_ITEM_HIST")
@AttributeOverrides({ @AttributeOverride(name = "id", column = @Column(name = "ORDER_ITEM_HIST_ID")) })
public class OrderItemHist extends AbstractSorsEntity {
    private static final long serialVersionUID = 1L;

    private OrderItem orderItem;
    private Date deliveryDate;
    private Integer quantity;

    /**
     * Returns current value of {@link #orderItem}.
     * 
     * @return the {@link #orderItem}.
     */
    @NotNull
    @ManyToOne
    @JoinColumn(name = "ORDER_ITEM_ID")
    public OrderItem getOrderItem() {
        return orderItem;
    }

    /**
     * Sets new value for {@link #orderItem}.
     * 
     * @param orderItem
     *            the new orderItem to set
     */
    public void setOrderItem(OrderItem orderItem) {
        this.orderItem = orderItem;
    }

    /**
     * Returns current value of {@link #deliveryDate}.
     * 
     * @return the {@link #deliveryDate}.
     */
    @NotNull
    @Temporal(TemporalType.DATE)
    @Column(name = "DELIVERY_DATE")
    public Date getDeliveryDate() {
        return deliveryDate;
    }

    /**
     * Sets new value for {@link #deliveryDate}.
     * 
     * @param deliveryDate
     *            the new deliveryDate to set
     */
    public void setDeliveryDate(Date deliveryDate) {
        this.deliveryDate = deliveryDate;
    }

    /**
     * Returns current value of {@link #quantity}.
     * 
     * @return the {@link #quantity}.
     */
    @NotNull
    @Min(1)
    @Column(name = "QUANTITY")
    public Integer getQuantity() {
        return quantity;
    }

    /**
     * Sets new value for {@link #quantity}.
     * 
     * @param quantity
     *            the new quantity to set
     */
    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }
}
